<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\YjUser;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Controllers\AdminController;

class YjUserController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected  $status = [
        1 => "未处理",
        2 => "已处理"
    ] ;
    protected function grid()
    {
        return Grid::make(new YjUser(), function (Grid $grid) {
            $grid->id->sortable();
            $grid->user;
            $grid->phone;
            $grid->status->using($this->status);
            $grid->created_at->sortable();
            $grid->disableCreateButton();
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');

            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new YjUser(), function (Show $show) {
            $show->id;
            $show->user;
            $show->phone;
            $show->status->using($this->status);
            $show->created_at;
            $show->updated_at;
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new YjUser(), function (Form $form) {

                $form->select("status",__("处理状态"))->options($this->status) ;
        });
    }
}
